#include<bits/stdc++.h>
//luogu_P1540

int Hash[1003] = {0};
std::queue<int> mem;

int main()
{
    int m, n;
    scanf("%d%d", &m, &n);
    int cnt = 0;
    int temp;
    while(n--)
    {
        scanf("%d", &temp);
        if(Hash[temp] != 1)
        {
            Hash[temp] = 1;
            mem.push(temp);
            if(mem.size() > m)
            {
                Hash[mem.front()] = 0;
                mem.pop();
            }
            cnt++;
        }
    }
    printf("%d", cnt);
    return 0;
}
